package com.muyu.danmo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.muyu.system.domain.DanmoOrder;
import com.muyu.system.domain.Vo.DanmoMarketOrderVO;
import com.muyu.system.domain.Vo.OrderItemVO;
import com.muyu.system.domain.Vo.OrderListVO;
import com.muyu.system.domain.Vo.StoreAddressVO;
import com.muyu.system.domain.dto.MarketOrderDTO;
import com.muyu.system.domain.dto.OrderListDTO;
import com.muyu.system.domain.dto.UpdateAddressDTO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单Mapper接口
 * 
 * @author yangle
 * @date 2025-01-18
 */
public interface DanmoOrderMapper extends BaseMapper<DanmoOrder>
{
    /**
     * 查询订单
     * 
     * @param id 订单主键
     * @return 订单
     */
    public DanmoOrder selectDanmoOrderById(Long id);

    /**
     * 查询订单列表
     * 
     * @param danmoOrder 订单
     * @return 订单集合
     */
    public List<DanmoOrder> selectDanmoOrderList(DanmoOrder danmoOrder);

    /**
     * 新增订单
     * 
     * @param danmoOrder 订单
     * @return 结果
     */
    public int insertDanmoOrder(DanmoOrder danmoOrder);

    /**
     * 修改订单
     * 
     * @param danmoOrder 订单
     * @return 结果
     */
    public int updateDanmoOrder(DanmoOrder danmoOrder);

    /**
     * 删除订单
     * 
     * @param id 订单主键
     * @return 结果
     */
    public int deleteDanmoOrderById(Long id);

    /**
     * 批量删除订单
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteDanmoOrderByIds(Long[] ids);

    void updateOrder(@Param("orderNo") String orderNo , @Param("orderStatus") int orderStatus);


    void updateMarketOrder(@Param("orderNo") String orderNo , @Param("orderStatus") int orderStatus);

    void updateMarketOrderPaymentTime(@Param("orderNo") String orderNo , @Param("orderStatus") int orderStatus,
                           @Param("paymentTime") LocalDateTime paymentTime);

    void updateMarketRefundOrder(@Param("refundOrderSn") String refundOrderSn ,
                                 @Param("orderStatus") int orderStatus, @Param("refundTime") LocalDateTime refundTime);

    void updateMarketOrderById(@Param("orderId") Long orderId , @Param("orderStatus") int orderStatus);

    void updateMember(@Param("orderNo") String orderNo , @Param("orderStatus") int orderStatus, @Param("tradingHours") LocalDateTime tradingHours);


    IPage<OrderListVO> orderList(IPage<?> page,  @Param("status") Integer status, @Param("orderSn") String orderSn,
                                 @Param("source")Integer source, @Param("storeId") Long storeId,@Param("userId") Long userId);

    List<OrderItemVO> orderListItem(Long orderId);


    Integer findSkuNum(Long skuId);

    BigDecimal findSkuPrice(Long skuId);

    void  updateSkuNum(@Param("skuId") Long skuId, @Param("num") Integer num);

    String findMarketOrderById(Long id);

    void updateMarketOrderAddressById(@Param("dto") UpdateAddressDTO updateAddressDTO);

    Integer findMarketOrderStatusByPayId(Long id);

    void updateMarketOrderDTO(@Param("dto") MarketOrderDTO marketOrderDTO);


    List<DanmoMarketOrderVO> findMarketOrder(@Param("orderStatus") Integer orderStatus);


    /**
     * 获取商户的默认地址
     * @param id
     * @return
     */
    StoreAddressVO findStoreAddressById(Long id);

    /**
     * 获取普通用户的默认地址
     * @param id
     * @return
     */
    StoreAddressVO findUserAddressById(Long id);


    Long findIdByRefundOrderSn(@Param("refundOrderSn") String refundOrderSn);

    Long findMarketProductsByRefundOrderSn(@Param("refundOrderSn") String refundOrderSn);


    void deleteMarketOrderById(Long id);


    Long findStoreById(Long id);

    /**
     * 修改书画交易商品
     * @param orderNo
     */
    void updateMarketProducts(@Param("orderNo") String orderNo);


    /**
     * 修改书画交易商品状态
     * @param id
     */
    void updateMarketProductsById(@Param("id") Long id);

    /**
     * 根据订单号查询卖家用户id
     * @param bizOrderNo
     * @return
     */
    Long findSellerUserIdByBizOrderNo(String bizOrderNo);

    /**
     * 根据订单id查询卖家用户id
     * @param id
     * @return
     */
    Long findSellerUserIdById(Long id);

    /**
     * 根据订单id，查询买家用户id
     * @param id
     * @return
     */
    Long findUserIdById(Long id);






}
